{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python \t\t3.6\n",
      "Tensorflow \t1.0.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Keras \t\t2.0.3\n"
     ]
    }
   ],
   "source": [
    "import sys; print('Python \\t\\t{0[0]}.{0[1]}'.format(sys.version_info))\n",
    "import tensorflow as tf; print('Tensorflow \\t{}'.format(tf.__version__))\n",
    "import keras; print('Keras \\t\\t{}'.format(keras.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline \n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('ggplot')\n",
    "\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#linear regression, with additive noise\n",
    "f = lambda x, e: 2*x + 3 + e\n",
    "f_vec =  np.vectorize(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samples = 1000\n",
    "e_data = np.random.normal(0.0, 0.2, samples)\n",
    "x_data = np.random.rand(samples)\n",
    "y_data = f_vec(x_data,e_data)\n",
    "\n",
    "# transform into columns\n",
    "x_data = x_data.reshape(-1,1)\n",
    "y_data = y_data.reshape(-1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHq5JREFUeJzt3X9M1Pf9B/Dn5447KHB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vXmtG0tGnpS39/PwYGBmw7nJpJS38uX76MK1eu\n4Fe/+hX27NmDnp4es5upiZa+PPzww3j//ffxk5/8BM8++yx+/OMfm91M3QwNDSEUCiVep/pezcdW\n4Sezrq4u9Pf343vf+57VTVkUVVXx0ksv4Yc//KHVTdGNqqq4cuUKmpqa8MQTT+DIkSMYHR21ulmL\n8ve//x0bNmzA888/jyeffBKHDx+GqqpWN8tStgq/YDCIwcHBxOvBwUEEg8F5j4nH4xgbG0MgEDC1\nnVpp6Q8A9Pb24i9/+Qt27txp2+Fiqr7cuHEDly5dwt69e/H444/jww8/xP79+/HRRx9Z0dyUtP5b\nC4fDyMrKwpIlS7B06VJcuXLF7KampKUvJ06cQFVVFQCgrKwMsVjMtiOmVILBIAYGBhKv5/tepWKr\n8CstLcWVK1fw3//+F5OTkzh58iTCs57RW1FRgc7OTgBTs4rl5eVQFMWC1qampT8ff/wx/vjHP2Ln\nzp22vaYEpO5Lbm4uXnjhBbS2tqK1tRWrVq3Czp07bTvbq+V3881vfhN9fX0AgOvXr+PKlSu48847\nrWjugrT0JRQK4dy5cwCATz/9FLFYDAUFBVY0N2PhcBhdXV0QQuDChQvIzc1d1DVM2+3wOHPmDP78\n5z9DVVV85zvfwebNm9HW1obS0lKEw2FEo1G0tLTg448/Rn5+PhobG235D3Jaqv4888wz+OSTT3D7\n7bcDmPpHumvXLotbPbdUfZnp6aefxg9+8APbhh+Quj9CCLz00kvo6emBx+PB5s2bce+991rd7Dml\n6sunn36KI0eO4MaNGwCArVu34qtf/arFrZ7b7373O/z73//GyMgICgsLsWXLFkxOTgIA7r//fggh\n8MILL+Cf//wn/H4/GhoaFvXvzHbhR0RkBlsNe4mIzMLwIyIpMfyISEoMPyKSEsOPiKTE8CMiKTH8\niEhK/w9Hl94wOl37rgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11b9e8898>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x_data[:100], y_data[:100], 'r.')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.01, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import tensorlayer as tl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Set parameters\n",
    "training_iteration = 5\n",
    "batch_size = 5\n",
    "display_step = 1\n",
    "learning_rate = 0.01\n",
    "\n",
    "FLAGS = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# TF graph input\n",
    "x = tf.placeholder('float', [None, 1]) \n",
    "y = tf.placeholder('float', [None,1]) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  [TL] InputLayer  input_layer: (?, 1)\n",
      "  [TL] DenseLayer  output_layer: 1 identity\n"
     ]
    }
   ],
   "source": [
    "network = tl.layers.InputLayer(x, name='input_layer')\n",
    "network = tl.layers.DenseLayer(network, n_units=1, act=tf.identity, name='output_layer')\n",
    "\n",
    "y_hat = network.outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "cost = tf.reduce_sum(tf.pow(y_hat-y,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train_params = network.all_params\n",
    "\n",
    "with tf.name_scope(\"train\") as scope:\n",
    "    # Gradient descent\n",
    "    optimizer = tf.train.GradientDescentOptimizer(learning_rate)\n",
    "    learn     = optimizer.minimize(cost, var_list=train_params)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Initializing the variables\n",
    "init = tf.global_variables_initializer()\n",
    "\n",
    "# Merge all summaries into a single operator\n",
    "merged_summary_op = tf.summary.merge_all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Launch the graph\n",
    "sess = tf.InteractiveSession()\n",
    "sess.run(init)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Logs and graph for tensorboard\n",
    "summary_writer = tf.summary.FileWriter('./tensorboard', graph=sess.graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Test the model, Calculate accuracy\n",
    "mse= tf.reduce_mean(tf.pow(y_hat-y,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start training the network ...\n",
      "Epoch 1 of 5 took 0.110046s\n",
      "   val loss: 0.262985\n",
      "   val acc: 0.052597\n",
      "Epoch 2 of 5 took 0.081643s\n",
      "   val loss: 0.227078\n",
      "   val acc: 0.045416\n",
      "Epoch 3 of 5 took 0.086396s\n",
      "   val loss: 0.244856\n",
      "   val acc: 0.048971\n",
      "Epoch 4 of 5 took 0.078172s\n",
      "   val loss: 0.255855\n",
      "   val acc: 0.051171\n",
      "Epoch 5 of 5 took 0.078498s\n",
      "   val loss: 0.261709\n",
      "   val acc: 0.052342\n",
      "Total training time: 0.441933s\n"
     ]
    }
   ],
   "source": [
    "# train the network\n",
    "tl.utils.fit(sess, network, learn, cost, x_train, y_train, x, y,\n",
    "             acc=mse, batch_size=5, n_epoch=5, print_freq=1, \n",
    "             X_val=x_test, y_val=y_test, eval_train=False)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start testing the network ...\n",
      "   test acc: 0.052342\n"
     ]
    }
   ],
   "source": [
    "# evaluation\n",
    "tl.utils.test(sess, network, mse, x_test, y_test, x, y, batch_size=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Regression a = 2.0, b = 3.0\n"
     ]
    }
   ],
   "source": [
    "w_ = network.all_params[0].eval()[0][0]\n",
    "b_ = network.all_params[1].eval()[0]\n",
    "print(\"Regression a = {:.2}, b = {:.2}\".format(w_, b_))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.66798525,  4.31360817],\n",
       "       [ 0.65917663,  4.29585552],\n",
       "       [ 0.55946627,  4.09489727],\n",
       "       [ 0.4925937 ,  3.96012115],\n",
       "       [ 0.9452741 ,  4.87246084],\n",
       "       [ 0.15314049,  3.2759819 ],\n",
       "       [ 0.89588   ,  4.77291107],\n",
       "       [ 0.02567681,  3.01908946],\n",
       "       [ 0.2760092 ,  3.52361345],\n",
       "       [ 0.59691542,  4.17037296]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test_predict = sess.run(y_hat, feed_dict={x:x_test})\n",
    "np.hstack([x_test[:10], y_test_predict[:10]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+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mV3js2rWLdevW\n4XK5+O1vf0tOTg6FhYX06dOHzMxMbDYbK1as4LvvviMpKYkZM2Zo7h8neK7HI488wuHDh0lNTQUa\n/7HOnj07xKVun6e6tPTQQw9xyy23aDL8wHNdVFXl2WefZc+ePeh0OnJycvjVr34V6mKfxlM9fvjh\nB1atWkV9fT0A48aN44ILLghxqdu3dOlSvvzyS6qrq0lJSeGmm27C4XAAcPXVV6OqKmvWrOHzzz/H\naDQyadKkLv/70mT4CSFEoGnusVcIIYJBwk8IEZUk/IQQUUnCTwgRlST8hBBRScJPCBGVJPyEEFHp\n/wOWr7P8tQ2KzAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11f083748>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x_data[:100], y_data[:100], 'r.')\n",
    "plt.plot(x_test, y_test_predict, 'bo')\n",
    "plt.plot([b_,w_*1+b_], 'b-')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Close the Session when we're done.\n",
    "sess.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
